﻿using System.IO;
using Xunit;

namespace Sustainalytics.FTPReport.BusinessLogic.Tests
{
    public class FtpManagerTest
    {
        ReportsFtpManagement reportManagement = null;
        string ftpUsername = "Stagetest",
                ftpPassword = "9^DFtgFsL2",
                ftpServerAddress = "52.210.53.173";
        string fileName = "test_171019.csv",
                directoryPath = "";
        int ftpServerPort = 21;
        bool enableSsl = false;

        string sftpUsername = "sFTP_Transfer",
               sftpPassword = "7sNNW4P-wz$FL![A",
               sftpServerAddress = "54.194.227.179",
               sftpDirectoryPath = "Work/Dev/";
        int sftpServerPort = 22;



        public class FtpUploadTest : FtpManagerTest
        {
            //[Fact]
            //public void ShouldUploadToSSHFTP()
            //{
            //    reportManagement = new ReportsFtpManagement();
            //    reportManagement.StartGenerating();

            //    Assert.Equal(1, 1);
            //}

            [Fact]
            public void ShouldUploadToFTP()
            {
                reportManagement = new ReportsFtpManagement();
                byte[] fileContent = File.ReadAllBytes("D:/" + fileName);

                reportManagement.UploadToFTPOrFPTSSLServerGenericNew(ftpUsername, ftpPassword, ftpServerAddress, ftpServerPort, fileName, fileContent, enableSsl, directoryPath);

                Assert.Equal(1, 1);
            }

            [Fact]
            public void ShouldUploadToSFTP()
            {
                reportManagement = new ReportsFtpManagement();
                byte[] fileContent = File.ReadAllBytes("D:/" + fileName);

                reportManagement.UploadToSSHFTPServerNew(sftpUsername, sftpPassword, sftpServerAddress, sftpServerPort, fileName, fileContent, sftpDirectoryPath);

                Assert.Equal(1, 1);
            }

            [Fact]
            public void ShouldCheckFTPSettings()
            {
                reportManagement = new ReportsFtpManagement();

                var result = reportManagement.IsConnectionToSSHFTPServerAllowedNew(sftpUsername, sftpPassword, sftpServerAddress, sftpServerPort);
                Assert.True(result);
            }
        }

    }
}
